package org.apache.zookeeper;

import org.apache.zookeeper.server.paxos2.Configuration;

/**
 * Created by IntelliJ IDEA.
 * User: wangw
 * Date: 2011-6-1
 * Time: 19:12:49
 * To change this template use File | Settings | File Templates.
 */
public abstract class TimeoutHandler {

    long timeoutTime;

    private boolean finished = false;

    public TimeoutHandler(long timeoutInterval){
        this.timeoutTime = System.currentTimeMillis() + timeoutInterval;
    }

    public void resetTimeout(long timeoutInterval){
        this.timeoutTime = System.currentTimeMillis() + timeoutInterval;    
    }

    /*public void resetTime(){
        this.time = System.currentTimeMillis();
    }*/

    public long getTimeoutTime(){
        return timeoutTime;
    }

    public synchronized void finish(){
        finished = true;
    }

    public boolean isFinished(){
        return finished;
    }

    public abstract void handleTimeout();

}
